﻿using IDAL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class D_Shape : IShape
    {
        public void Add(Shape item)
        {
            CakeEntities db = new CakeEntities();
            db.Shape.Add(item);
            db.SaveChanges();
        }

        public void Delete(int id)
        {
            CakeEntities db = new CakeEntities();
            db.Shape.Remove(db.Shape.Find(id));
            db.SaveChanges();
        }

        public Shape FindById(int id)
        {
            CakeEntities db = new CakeEntities();
            return db.Shape.Find(id);
        }

        public List<Shape> GetAll()
        {
            CakeEntities db = new CakeEntities();
            return db.Shape.ToList();
        }

        public void Updata(int id, Shape item)
        {
            CakeEntities db = new CakeEntities();
            var data=db.Shape.Find(id);
            if (data != null)
            {
                data.ShapeName = item.ShapeName;
                db.SaveChanges();
            }
        }
    }
}
